import { login } from '@/services/login';
import { setToken } from '@/utils/auth';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import {
  LoginForm,
  ProFormText,
  ProConfigProvider,
} from '@ant-design/pro-components';
import './index.css';
export default () => {
  const onFinish = async (values: { password: string; userName: string }) => {
    const data = await login(values);
    setToken(data.token);
    location.href = process.env.PUBLIC_PATH as string;
  };
  return (
    <ProConfigProvider hashed={false}>
      <div
        style={{
          height: 'calc(100vh)',
  
        }}
        className='box'
      >
        <LoginForm
          title="益阳市公安局民警风采录入系统"
          onFinish={onFinish}
          style={{
            marginTop: '50px',
            justifyContent: 'center',
            alignItems: 'center',
          }}
          className="login-form"
        >
          <>
            <ProFormText
              name="userName"
              fieldProps={{
                size: 'large',
                prefix: <UserOutlined className={'prefixIcon'} />,
              }}
              placeholder={'请输入用户名或者手机号码'}
              rules={[
                {
                  required: true,
                  message: '请输入用户名或者手机号码!',
                },
              ]}
            />
            <ProFormText.Password
              name="password"
              fieldProps={{
                size: 'large',
                prefix: <LockOutlined className={'prefixIcon'} />,
              }}
              placeholder={'请输入密码'}
              rules={[
                {
                  required: true,
                  message: '请输入密码！',
                },
              ]}
            />
          </>
        </LoginForm>
      </div>
    </ProConfigProvider>
  );
};
